<?php
header("Content-Type: text/html; charset=utf8");
mysql_connect("localhost", "site_admin", "site_admin" );
mysql_select_db("site_db");
$result = mysql_query("SELECT * FROM site_posts");
$fields = mysql_num_fields($result);
$rows   = mysql_num_rows($result);
$table  = mysql_field_table($result, 0);
echo "Your '" . $table . "' table has " . $fields . " fields and " . $rows . " record(s)<br>";
echo "The table has the following fields:<br>";
for ($i=0; $i < $fields; $i++) {
    $type  = mysql_field_type($result, $i);
    $name  = mysql_field_name($result, $i);
    $len   = mysql_field_len($result, $i);
    $flags = mysql_field_flags($result, $i);
    echo $type . " " . $name . " " . $len . " " . $flags . "<br>";
}
echo "====================<br>";
for( $j=0; $j<$rows;$j++ ){
	$row = mysql_fetch_assoc($result);
	for ($i=0; $i < $fields; $i++) {
	    $type  = mysql_field_type($result, $i);
	    $name  = mysql_field_name($result, $i);
	    $len   = mysql_field_len($result, $i);
	    $flags = mysql_field_flags($result, $i);
	    echo "name-value:". $name;
	    echo "-".$row[$name]."			";
	}
	echo "<br>";
}
mysql_free_result($result);
mysql_close();

echo "====================<br>";
// 获取数据库连接
$db_connection =  new mysqli( "localhost", "site_admin", "site_admin", "site_db" );
  	
  	// 连接数据库
  	if( mysqli_connect_errno() )
		{
			echo "MySQL connect error";
			exit();
		}
$query_post = "select p.post_date, p.content, p.visit_times".
  				" from site_posts p where p.status=1 and p.category='about' and p.id=1";
  		if( $result = $db_connection->query($query_post) ){
  			$rs_rows = $result->num_rows;
  			$one_row = $result->fetch_assoc();
  			$p_content = $one_row['content'];
  			$p_date = $one_row['p_date'];
  			$p_count=$one_row['visit_times'];
  			echo $p_content."&&&".$p_date."&&&".$p_count;
  		}
  		$db_connection->close();
?>